Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Fix/disable RedHat System.Globalization, System.IO.Pipes, System.IO.FileSystem failures #24340

Merged
merged 9 commits into from
Oct 9, 2017

Conversation

krwq
Copy link
Member

@krwq krwq commented Sep 29, 2017

Fixes: https://github.com/dotnet/corefx/issues/24304
Fixes: https://github.com/dotnet/corefx/issues/23628
Fixes: https://github.com/dotnet/corefx/issues/23630 (port disable from master)
Contributes to: https://github.com/dotnet/corefx/issues/21920

Original fix made by @tarekgh will require changes to CoreCLR (add ICU version detection to native code) which is likely not appropriate as servicing change which does not fix any product bugs.

This PR replaces #24338 which was against dev/release/2.0.0

@mmitche
Copy link
Member

mmitche commented Sep 29, 2017

@dotnet-bot test this please

@krwq
Copy link
Member Author

krwq commented Sep 29, 2017

@danmosemsft Is it ok to merge @janvorli's PRs here to enable RHEL 6? I'd like to test this before merging this PR:
https://github.com/dotnet/corefx/pull/24285/commits
https://github.com/dotnet/corefx/pull/24331/commits

@tarekgh
Copy link
Member

tarekgh commented Sep 29, 2017

@krwq I think you are missing some part in how we detect RedHat mainly in the method ParseOsReleaseFile. I'll try to send you a link to the code we have done in 2.1 to do that

@tarekgh
Copy link
Member

tarekgh commented Sep 29, 2017

@krwq please look at the implementation of the method ParseOsReleaseFile which we need to port.

https://github.com/dotnet/corefx/blob/master/src/CoreFx.Private.TestUtilities/src/System/PlatformDetection.Unix.cs#L84

@krwq
Copy link
Member Author

krwq commented Sep 29, 2017

@tarekgh it's already there but in PlatformDetection.cs and not PlatformDetection.Unix.cs

EDIT: aahh, I see - there is some special stuff about RHEL which is missing - thank you!

@@ -161,6 +161,7 @@ public static bool IsWinRT
public static bool IsNotFedoraOrRedHatOrCentos => !IsDistroAndVersion("fedora") && !IsDistroAndVersion("rhel") && !IsDistroAndVersion("centos");

public static bool IsFedora => IsDistroAndVersion("fedora");
public static bool IsRedHat69 => IsDistroAndVersion("rhel", "6.9") || IsDistroAndVersion("rhl", "6.9");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would check just the major version here, the minor one should not change the behavior, I believe.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave this as is for consistency with master - in this particular case we need to tell which version of ICU shipped with RedHat, I'm not sure what are the differences between 6.9 and other 6.X versions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no usable ICU version that ships with any version RedHat 6. We tell the users to install version 57.1 binary from the tarball provided on the ICU site. But even if there was one, RedHat never changes the major versions of libraries they ship when they bump the minor version. So 6.0, 6.1, ... 6.9 all would have the same major version of the library.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@janvorli what @krwq meant is in 2.1 branch we detect the ICU version at runtime. so we don't care how the ICU get installed on the machine anyway. The right way to check the globalization behavior is to check the ICU version and not the OS version. We don't do that in v 2.0 servicing branches because this will need a change in the release bits (System.Globalzation.Native) and not the test bits only. This is why we are just doing the minimum needed in the servicing branch to have the tests not failing there.

@karelz karelz added this to the 2.0.x milestone Oct 2, 2017
Copy link
Member

@danmoseley danmoseley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to ping shiproom for ok to submit.

@danmoseley
Copy link
Member

@krwq they are about to lock down the branch, can you please get shiproom OK?

@dotnet-bot test Innerloop Tizen armel Debug Cross Build Innerloop Tizen armel Release Cross Build

@danmoseley
Copy link
Member

@dotnet-bot test Innerloop Tizen armel Release Cross Build

@krwq
Copy link
Member Author

krwq commented Oct 5, 2017

@danmosemsft I am currently not able to test if RedHat is fixed without pushing my commit - there is no CI or any complete instructions how to set up RedHat 6.9 (closest are @janvorli's instructions https://github.com/dotnet/core/blob/master/Documentation/build-and-install-rhel6-prerequisites.md but they only let you run app and not build corefx) - I'm working on that right now. Could this PR wait a little? It doesn't seem like we will be changing any product code here..

@danmoseley
Copy link
Member

@krwq sure. If it's too much of a pain we could ask to merge anyway, the change seems really hard to get wrong. Did you ask MattGal whether you could borrow a build machine that's already set up?

@janvorli
Copy link
Member

janvorli commented Oct 5, 2017

@krwq you can test it in docker container, the image microsoft/dotnet-buildtools-prereqs:centos-6-783abde-20171304101322 that we use in the lab for building has all the necessary prerequisites.

On a local Linux machine or VM, make sure you have docker installed and then do this:

sudo docker run --net host -it --name my_centos_6 microsoft/dotnet-buildtools-prereqs:centos-6-783abde-20171304101322 /usr/bin/scl enable python27 bash

That will get you inside the docker container as a 'root' user. You can then clone the corefx repo using git and build / test everything.

The important thing though is to prefix invocation of all the build.sh, run-tests.sh etc with LD_LIBRARY_PATH=/usr/local/lib. So e.g.

LD_LIBRARY_PATH=/usr/local/lib ./build.sh

Once you are done with your work, exit the container using the “exit” command.

If you want to resume working on the CentOS 6 stuff, use the following command to re-enter the container:

sudo docker start -ai my_centos_6

@krwq
Copy link
Member Author

krwq commented Oct 6, 2017

@janvorli thank you! I was able to build release/2.0.0 successfuly (on master I still get build errors). I think there might be a problem with the RedHat docker image:

> cat /etc/redhat-release
CentOS release 6.9 (Final)

this is causing OS detection to not work correctly - I'll update the test to accept both CentOS and RedHat for now since there shouldn't be any difference

@janvorli
Copy link
Member

janvorli commented Oct 6, 2017

@krwq rhel and centos are equivalent and so at all places of detection I was adding, both systems get rid "rhel.6" intentionally. I think we should follow the suite here as well so that we have it detected everywhere the same way.

@krwq krwq force-pushed the rh_test_failures branch from 531e4ee to a85637c Compare October 6, 2017 18:34
@krwq
Copy link
Member Author

krwq commented Oct 6, 2017

@janvorli thanks! I'll unify rhel and centos in this PR


public static bool IsFedora => IsDistroAndVersion("fedora");
public static bool IsRedHatFamily => IsRedHatFamilyAndVersion();
public static bool IsRedHatFamily7 => IsRedHatFamilyAndVersion("7");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For CentOS and RHEL 7, there is a difference in the version reported via /etc/os-release. CentOS reports just 7, but RHEL reports 7.x where x is the minor version. So this needs to be taken into account, unless I am missing something, there is no version normalization code anywhere.
That is different for version 6 where there is no /etc/os-release and the /etc/redhat-release contains version 6.x, that means including the minor version for both RHEL and CentOS.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i've added additional checks in IsRedHatFamilyAndVersion and RedHatVersionEqual

@krwq krwq changed the title [WIP] Fix RedHat System.Globalization failures Fix RedHat System.Globalization, System.IO.Pipes, System.IO.FileSystem failures Oct 6, 2017
@krwq krwq changed the title Fix RedHat System.Globalization, System.IO.Pipes, System.IO.FileSystem failures Fix/disable RedHat System.Globalization, System.IO.Pipes, System.IO.FileSystem failures Oct 6, 2017
@tarekgh
Copy link
Member

tarekgh commented Oct 7, 2017

@krwq thanks for cleaning up this area and doing the right thing. I have added a couple of comments.

{
ret.Id = "centos";
}
else if (line.StartsWith("Red Hat", StringComparison.OrdinalIgnoreCase))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krwq could you please remove this else block? it is not really needed and can confuse people for having some non-standard redhat distro. Also, could you please remove it from the master too when you are applying some changes there as we talked before?

@@ -158,9 +158,13 @@ public static bool IsWinRT
public static bool IsWindowsSubsystemForLinux => m_isWindowsSubsystemForLinux.Value;
public static bool IsNotWindowsSubsystemForLinux => !IsWindowsSubsystemForLinux;

public static bool IsNotFedoraOrRedHatOrCentos => !IsDistroAndVersion("fedora") && !IsDistroAndVersion("rhel") && !IsDistroAndVersion("centos");
public static bool IsNotFedoraOrRedHatFamily => !IsDistroAndVersion("fedora") && !IsRedHatFamily;

public static bool IsFedora => IsDistroAndVersion("fedora");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move IsFedora and IsRedHatFamily before the line of IsNotFedoraOrRedHatFamily to ensure the right order of the static initialization.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pending

@@ -158,9 +158,13 @@ public static bool IsWinRT
public static bool IsWindowsSubsystemForLinux => m_isWindowsSubsystemForLinux.Value;
public static bool IsNotWindowsSubsystemForLinux => !IsWindowsSubsystemForLinux;

public static bool IsNotFedoraOrRedHatOrCentos => !IsDistroAndVersion("fedora") && !IsDistroAndVersion("rhel") && !IsDistroAndVersion("centos");
public static bool IsNotFedoraOrRedHatFamily => !IsDistroAndVersion("fedora") && !IsRedHatFamily;
Copy link
Member

@tarekgh tarekgh Oct 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use IsFedora instead of IsDistroAndVersion("fedora"). ensure IsFedora is moved before this line

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pending


public static bool IsFedora => IsDistroAndVersion("fedora");
public static bool IsRedHatFamily => IsRedHatFamilyAndVersion();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add comment that this is cover RedHat and Centos. Just in case if anyone want to check Centos and don't know it is covered by this property.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pending

IdVersionPair v = ParseOsReleaseFile();
bool isRedHat = v.Id == "rhel";
// RedHat includes minor version. We need to account for that when comparing
if ((isRedHat || v.Id == "centos") && (versionId == null || v.VersionId == versionId || (isRedHat && RedHatVersionEqual(versionId, v.VersionId))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the version check logic can be written in a more global way which can include checking only concerned parts of the version. this can be done in 2 ways:

1- either you do versionId.Split('.') which will produce an array of strings of the version parts and also do v.VersionId.Split('.'). Then try to check versionId parts against v.VersionId parts (regardless how many parts is in versionId).
2- other idea is when we are reading the distro info, we read the version string and convert it to Version struct. then we can just use numbers instead of strings all the time.

if we do one of these ideas, we don't have to distinguish between isRedHat or not as you are doing in your code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pending (string.split) but might get changed after fixing Eric's comment

ret.VersionId = versionId.Substring(1, versionId.Length - 2);
}
string fileName = null;
if (File.Exists("/etc/redhat-release"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be beneficial to use the RuntimeEnvironment class here? It is already doing all this logic, and it is how our customers get the current RID of the machine, and what version of RedHat we are on, etc.

I know the dependency would be a little inverted here (corefx code referencing core-setup code). But we do that today when using the "shared framework" to run tests. So there is precedent.

/cc @weshaggard

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would make core-setup necessary for running dotnet apps. Now it is not needed - you can just build coreclr and corefx and use corerun / coreconsole for running your app. I believe that's what the Samsung folks are using.
If we want to unify the detection code (which would be great), I think we should rather move it to corefx and let core-setup use it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this was only for test code?

As for moving the real logic into CoreFX- yes please!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I am sorry, I've missed that it is for tests only. You are right.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eerhardt does RuntimeEnvironment is a public class which can easily take a dependency on? Also, how easy we can add more properties to it? I am asking because for the tests we need to be flexible of adding more properties to the PaltformDetection code and customize it to fit the cases needed in the tests. in another word, for tests, I prefer the flexibility even if we duplicate some of such features.

Another thing, this PR is for 2.0 servicing branch which I prefer to minimize the changes here, so if we decide to take a dependency on RuntimeEnvironment, I prefer to do it in master and not in 2.0 branch.

Copy link
Member

@tarekgh tarekgh Oct 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weshaggard why this functionality is not exposed from RuntimeInformation class instead? why have we introduced RuntimeEnvironment while this can fit better in RuntimeInformation?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may get moved down eventually but today the RID stuff is only on the RuntimeEnviroment class.

Copy link
Member Author

@krwq krwq Oct 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I see advantage of using RuntimeEnvironment here I'll exclude this change request from 2.0.0 PR as it will introduce too much churn because PlatformDetection currently lives in the Common folder meaning every test project will now have to depend on PlatformAbstraction. I'll change it in the PR against master as we can change just test utils project.

If you strongly feel we should do that in 2.0.0 branch I'll do it but currently think we should limit 2.0.0 changes to minimum.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, I'll do this for master branch but will exclude for servicing branch (because too many projects will have to be touched)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing, this PR is for 2.0 servicing branch which I prefer to minimize the changes here, so if we decide to take a dependency on RuntimeEnvironment, I prefer to do it in master and not in 2.0 branch.

I'll do this for master branch but will exclude for servicing branch (because too many projects will have to be touched)

Works for me. Thanks.

@krwq
Copy link
Member Author

krwq commented Oct 9, 2017

@vancem I believe the OSX failure might be related to your PR: #24342

@vancem
Copy link
Contributor

vancem commented Oct 9, 2017

Please ignore the failure in BasicEventSourceTests.TestEventCounter.Test_Write_Metric_EventListener.
The tests is flaky, it has already been fixed in master. I will disable it here.

@krwq krwq merged commit 00788da into dotnet:release/2.0.0 Oct 9, 2017
@krwq
Copy link
Member Author

krwq commented Oct 9, 2017

Thank you @vancem! Merging since the failures are unrelated

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants